<!DOCTYPE html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width,target-densitydpi=high-dpi,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  <title>街市腊无</title>
  <link rel="stylesheet" href="__PUBLIC__/css/style.css">
  	<script language="javascript">
  function check(){
    var a = /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|14[57]\d{8}|15\d{9}|18\d{9}$/;
    if(formwrite.uPhone.value.length != 11 || !formwrite.uPhone.value.match(a)){
      alert("请填写正确的手机号码！");
      formwrite.uPhone.focus();
      return false;
    }
    else{
      return true;
    }

  }
</script>
</head>

<body>
<if condition="$info.id lt 1">
	<form action="__GROUP__/User/check" name="formwrite" method="post" onsubmit="return check(formwrite)">
    <div id="popBox" style="display: block;">
      <div class="popBox">
        <input type="text" placeholder="请输入手机号" name="phone" id="uPhone">
        <button  class="btnComfirm" type="submit" name="button">确定</button>
      </div>
    </div>
  </form>
</if> 
 <!--form action="__GROUP__/User/hit" method="post"-->
  <div id="alertBox">
    <div class="alertBox">
      <h2>提示</h2>
      <p>确定要使用该优惠券么？</p>
      <button class="btnCancel" type="button" name="button">取消</button>
      <button class="btnComfirm" type="button" name="button" style="cursor:pointer;">确定</button>
        
    </div>
  </div>
   
  <div class="container">
    <div class="backg">
      <a href="__GROUP__/Index/index" style="position:absolute; width:8%">
        <img src="__PUBLIC__/img/an.png" style="width:100%" />
      </a>
      <img src="__PUBLIC__/img/flsh5-0118_01.png" style=" width: 100%; height: auto;" />
      <img src="__PUBLIC__/img/flsh5-0118_03.png" style=" width: 100%; height: auto;" />
      <img src="__PUBLIC__/img/flsh5-0118_05.png" style=" width: 100%; height: auto;" />
    <!--没有使用过的优惠券-->
   <foreach name="images" item="vo" key="k">
      <div class="coupon" title="{$vo.id}">
        <img id="unimage" src="__PUBLIC__/img/{$vo.yhpic}" style=" width: 100%; height: auto;" />
        <input type="hidden" name="picid" id="picid" value="{$vo.id}"/>
        </div> 
  </foreach>   
   <!--使用过的优惠券-->
   <foreach name="images2" item="vs">
      <div title="{$vs.id}"> 
        <img src="__PUBLIC__/img/flsh5-2haodifang_14.png" style=" width: 100%; height: auto;" />
       </div>
    </foreach>    
    </div>
  </div>
  <input type="hidden" name="userid" id="userid" value="{$info.id}"/>
 
  <script src="__PUBLIC__/bower_components/jquery/dist/jquery.min.js"></script>
  <script src="__PUBLIC__/js/main-n.js"></script>
  <script type="text/javascript">
  $(function(){
	  show();
	  function show(){
	  var uid=$("#userid").val();
	  if(uid>0){
		   $('#popBox').fadeOut('fast');
		  }else{
		    $('#popBox').fadeIn('fast');
			  }
	       }
	  });	
</script>

<script type="text/javascript">
 $(function(){
	 prepareAlertBox();
	 function prepareAlertBox() {
	var coupon = $('.coupon');
	var btnComfirm = $('.btnComfirm');
	var btnCancel = $('.btnCancel');
	var num;
	
	$(coupon).on('click', function() {
		$('#alertBox').fadeIn('fast');
		num = parseInt(this.getAttribute('title'));
	});
	$(btnComfirm).on('click', function() {
		var picid=num;
		var userid=$("#userid").val();
		var data={
			pid : picid,
			uid : userid,
			}
		$.get("__GROUP__/User/hit",data,function(msg){
			
			update();
			},'json');
			
		function update(){
					window.location.reload();
					}  
	});
	$(btnCancel).on('click', function() {
		$('#alertBox').fadeOut('fast');
	});
}
	 });
</script>

</body>

</html>
